module.exports = app => {
    const { STRING, INTEGER, DATE, BIGINT, TINYINT } = app.Sequelize;

    const Conversation = app.model.define('conversation', {
        id: {
            type: BIGINT.UNSIGNED,
            primaryKey: true,
            autoIncrement: true,
        },
        user1_id: { type: BIGINT.UNSIGNED, allowNull: false },
        user2_id: { type: BIGINT.UNSIGNED, allowNull: false },
        last_message_id: { type: BIGINT.UNSIGNED, allowNull: true },
        last_message_at: DATE,
        unread_count: { type: INTEGER, allowNull: true, defaultValue: 0 },
        is_active: { type: TINYINT, allowNull: false, defaultValue: 1 },
        created_at: DATE,
        updated_at: DATE,
    }, {
        tableName: 'conversations',
        timestamps: false,
    });

    return Conversation;
};